package org.gdstash.combobox;

import com.jidesoft.swing.ComboBoxSearchable;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
import javax.swing.*;
import java.awt.*;
 
public class ComboBoxWithSearchExample {
    public static void main(String[] args) {
        JFrame frame = new JFrame("ComboBox with Search");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
        // 创建一个普通的JComboBox
        JComboBox<String> comboBox = new JComboBox<>(new String[]{"Item 1", "Item 2", "Item 3", "Item 4", "Item 5"});
        comboBox.setEditable(true);
        // 使用SwingX的AutoCompleteDecorator来装饰JComboBox，使其具有搜索功能
        AutoCompleteDecorator.decorate(comboBox);

        frame.add(comboBox, BorderLayout.NORTH);
        frame.setSize(300, 200);
        frame.setVisible(true);
    }
}